#include <stdio.h>
#include <stdlib.h>
#include<sys/wait.h>
#include <unistd.h>
int main(){
  pid_t id = fork();
  if(id==-1){
    perror("fork error");
  }
  else if(id==0){
    //child
    int count=0;
    while(count<3){
      printf("child[%d] is running...\n",getpid());
      sleep(1);
      count++;
    }
    exit(88);
  }
//father
printf("fater wait before\n");
int st=0;
pid_t ret = waitpid(id,&st,0);
if(WIFEXITED(st) && ret==id){
  printf("child exit code: %d\n",WEXITSTATUS(st));
}
else{
  printf("wait child faild!\n");
}
printf("father wait after\n");
  return 0;
}
